<?php
/**
 * Template Name: My Venue Pitches
 */

get_header(); ?>

<div class="container">
    <h1><?php the_title() ?></h1>

    <div class="row-fluid">
    </div>

    <div class="row-fluid">
        <div class="span8">
            <div class="card grey">
                <a class="btn btn-primary pull-right">Add Pitch &raquo;</a>
                <h2 class="title">Pitches</h2>

                <?php
                $name = get_user_relation_data('venue','name',get_user_id());
                query_posts(array( 'post_type' => 'pitches','showposts' => 100));
                while (have_posts()) : the_post();
                    if (get_relation_data('venue','name') == $name) {
                        ?>

                        <div class="card clearfix" style="border-radius: 3px">
                            <h3><a href="<?php the_permalink(); ?>"><?php the_field('pid'); ?></a></h3>
                            <a href="<?php the_permalink() ?>">
                                <?php $image = wp_get_attachment_image_src(get_field('image_1'), 'pitch-main');
                                if (get_field('image_1')) { ?>
                                    <img style="margin:0 15px 15px 0; width:300px; float:left; border-radius:3px;" src="<?php echo $image[0]; ?>"
                                         alt="<?php echo get_the_title(get_field('image_1')) ?>"/>
                                    <?php } else { ?>
                                    <img style="margin:0 15px 15px 0; width:300px; float:left; border-radius:3px;"
                                         src="http://pitchwise.co.uk/wp-content/uploads/2012/11/PitchWise-Logo-Green-658x300.png"
                                         alt="<?php echo get_field('pid') ?>"/>
                                    <?php }?>
                            </a>

                            <table class="table table-striped table-condensed table-bordered" style="width:263px">
                                <tbody>
                                <tr>
                                    <th>Size</th>
                                    <td><?php the_field('size'); ?> </td>
                                </tr>
                                <tr>
                                    <th>Surface</th>
                                    <td><?php the_field('surface'); ?> </td>
                                </tr>
                                <tr>
                                    <th>Floodlit</th>
                                    <td><?php the_field('floodlit'); ?> </td>
                                </tr>
                                <tr>
                                    <th>Indoor</th>
                                    <td><?php the_field('indoor'); ?> </td>
                                </tr>
                                </tbody>
                            </table>

                            <div style="clear:both;">
                                <a href="#" class="btn btn-primary">View Pitch &raquo;</a> &nbsp;
                                <a href="#" class="btn">Edit Pitch &raquo;</a>
                                <a href="#" class="btn btn-danger pull-right">Remove Pitch &raquo;</a>
                            </div>
                        </div>

                        <?php
                    }
                endwhile;
                ?>
            </div>
        </div>
        <div class="span4">
            <div class="card grey">
                <h2 class="title"></h2>

            </div>
        </div>
    </div>
</div>


<?php get_footer(); ?>